import time
def bubble_sort(nums):
    swapped = True
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
            if int(nums[i])> int(nums[i+1]):
               int(nums[i]), int(nums[i+1]) = int(nums[i + 1]), int(nums[i])                
               swapped = True
               
def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data
   

f1 = read2list("m1_sorted.txt")
f2 = read2list("m2_reverse.txt")
f3 = read2list("m3_shuffle.txt")


t0 = time.time() 
bubble_sort(f1)
t1 = time.time() 
print("Время",round((t0-t1)*1000))

t0 = time.time() 
bubble_sort(f2)
t1 = time.time() 
print("Время",round((t0-t1)*1000))

t0 = time.time() 
bubble_sort(f3)
t1 = time.time() 
print("Время",round((t0-t1)*1000))
